//
//  EnterpriseItemController.m
//  XTCloud
//
//  Created by QA on 2018/2/27.
//  Copyright © 2018年 ShangHai HaoLei Software Technology Co., Ltd. All rights reserved.
//

#import "EnterpriseItemController.h"
#import "GETableView.h"

#import "EnterprisesViewCell.h"
#import "UIImage+Color.h"
#import "NSArray+Format.h"
#import "NSDictionary+DataFormat.h"

#import "GEProgressBarTableViewCell.h"

@interface EnterpriseItemController ()

@property (nonatomic,strong) IBOutlet GETableView *tableView;
@property (nonatomic, strong) NSString *stationId;
@property (nonatomic, strong) NSArray *menuArray;

@end

@implementation EnterpriseItemController

- (instancetype)initWithStationId:(NSString*)stationId menuArray:(NSArray*)menuArray
{
    self = [super init];
    if(self){
        self.stationId = stationId;
        self.menuArray = menuArray;
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
    [self.navigationController.navigationBar lt_setBackgroundColor:[UIColor whiteColor]];
    
    //去除黑色阴影线
    UIImage *image = [UIImage imageWithColor:[UIColor colorWithWhite:0.9 alpha:1] size:CGSizeMake(SuperWidth, 0.5)];
    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 6){
        [self.navigationController.navigationBar setShadowImage:image];
    }
    
    //状态栏字体改变
    [self.navigationController setNavigationBarHidden:NO animated:YES];
    [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                                     [UIColorDispose colorWithHexString:@"#333333"], NSForegroundColorAttributeName,
                                                                     [UIFont systemFontOfSize:18.0], NSFontAttributeName, nil]];
}

#pragma mark - Table view data source

-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if ([tableView respondsToSelector:@selector(setSeparatorInset:)]) {
        [tableView setSeparatorInset:UIEdgeInsetsZero];
    }
    
    if ([tableView respondsToSelector:@selector(setLayoutMargins:)]) {
        [tableView setLayoutMargins:UIEdgeInsetsZero];
    }
    
    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
        [cell setLayoutMargins:UIEdgeInsetsZero];
    }
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return self.menuArray.count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 2;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    //菜单信息
    ModuleAuthorityEntity *entity = [_menuArray objectAtIndex:indexPath.section];
    
    //标题栏
    if(indexPath.row == 0){
        static NSString *CellIdentifier = @"EnterprisesViewCell";
        EnterprisesViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (!cell) cell = [[EnterprisesViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier index:indexPath.row];
        cell.titleLabel.text = entity.title;
        
        //副标题设置
        if(entity.module.integerValue == 2){
            //原材采购
            cell.subTitleLabel.hidden = NO;
            cell.subTitleLabel.text = @"单位:吨";
        } else if(entity.module.integerValue == 3){
            //原材消耗
            cell.subTitleLabel.hidden = NO;
            cell.subTitleLabel.text = @"单位:吨";
        } else {
            cell.subTitleLabel.hidden = YES;
        }
        
        return cell;
    }
    
    //绘制主体
    NSString *CellIdentifier = [NSString stringWithFormat:@"EnterprisesViewCell%ld-%ld",indexPath.section,indexPath.row];
    EnterprisesViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if(entity.module.integerValue == 1){//销售
        return [self getXSView:tableView path:indexPath];
        
    } else if(entity.module.integerValue == 2 ){//原材采购
        return [self getYCCGView:tableView path:indexPath];
        
    } else if(entity.module.integerValue == 3){//原材消耗
        return [self getYCXHView:tableView path:indexPath];
        
    } else if(entity.module.integerValue == 4){//柴油
        return [self getCYView:tableView path:indexPath];
        
    } else if(entity.module.integerValue == 5){//砼收款
        return [self getTSKView:tableView path:indexPath];
        
    } else if(entity.module.integerValue == 6){//应付款
        return [self getYFKView:tableView path:indexPath];
        
    } else if(entity.module.integerValue== 7){//砼方量统计
        return [self getTFLTJView:tableView path:indexPath];
    }
    
    return cell;
}

#pragma mark
#pragma mark - UITableViewDelegate

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if(section == 0) return 10;
    return 0.00001;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 10;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if(indexPath.row == 0) return 30;
    
    ModuleAuthorityEntity *entity = [_menuArray objectAtIndex:indexPath.section];
    //if(entity.module.integerValue == 1) return 195;
    //else if(entity.module.integerValue == 2) return 110;
    //else if(entity.module.integerValue == 3) return 110;
    if(entity.module.integerValue == 4) return 138;
    //else if(entity.module.integerValue == 5) return 90;
    //else if(entity.module.integerValue == 6) return 90;
//    else if(entity.module.integerValue == 7) return 135;
    
    //销售
    if(entity.module.integerValue == 1){
        NSString *keyValue = [NSString stringWithFormat:@"gkkb-%ld-%ld",indexPath.section,indexPath.row];
        EnterprisesViewCell *cell = [self.tableView getCellViewKey:keyValue];
        if(cell) return 195;
        else return 130;
    }
    
    //原材采购
    if(entity.module.integerValue == 2){
        GEProgressBarTableViewCell *progressBarCell = [self.tableView getCellViewInRow:0 inSection:indexPath.section];
        if(progressBarCell){
            NSArray *valueArray = [progressBarCell.objectValue objectAtIndexFormat:0];
            NSInteger height = 32 + valueArray.count*20 + 10;
            height = height <= 110 ? 120 : height;
            return height;
        }
    }
    
    //原材消耗
    if(entity.module.integerValue == 3){
        GEProgressBarTableViewCell *progressBarCell = [self.tableView getCellViewInRow:0 inSection:indexPath.section];
        if(progressBarCell){
            NSArray *valueArray = [progressBarCell.objectValue objectAtIndexFormat:0];
            NSInteger height = 32 + valueArray.count*20 + 10;
            height = height <= 110 ? 120 : height;
            return height;
        }
    }
    
    //砼收款
    if(entity.module.integerValue == 5){
        GEProgressBarTableViewCell *progressBarCell = [self.tableView getCellViewInRow:0 inSection:indexPath.section];
        if(progressBarCell){
            NSArray *valueArray = [progressBarCell.objectValue objectAtIndexFormat:0];
            NSInteger height = valueArray.count<=0 ? 120 : 90;
            return height;
        }
    }
    
    //应付款
    if(entity.module.integerValue == 6){
        GEProgressBarTableViewCell *progressBarCell = [self.tableView getCellViewInRow:0 inSection:indexPath.section];
        if(progressBarCell){
            NSArray *valueArray = [progressBarCell.objectValue objectAtIndexFormat:0];
            NSInteger height = valueArray.count<=0 ? 120 : 90;
            return height;
        }
    }
    
    //砼方量统计
    if(entity.module.integerValue == 7){
        GEProgressBarTableViewCell *progressBarCell = [self.tableView getCellViewInRow:0 inSection:indexPath.section];
        if(progressBarCell){
            NSArray *valueArray = [progressBarCell.objectValue objectAtIndexFormat:0];
            NSInteger height = 32 + valueArray.count*24 + 10;
            height = height <= 110 ? 110 : height;
            return height;
        }
    }
    
    return 110;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
}


#pragma mark

//销售
-(UITableViewCell*)getXSView:(UITableView *)tableView path:(NSIndexPath *)indexPath
{
    GEProgressBarTableViewCell *progressBarCell = [self.tableView getCellViewInRow:0 inSection:indexPath.section];
    if (progressBarCell == nil) {
        NSString *identifierBar = [NSString stringWithFormat:@"GEProgressBarTableViewCell%ld",indexPath.section];
        progressBarCell = [[GEProgressBarTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifierBar];
        progressBarCell.selectionStyle = UITableViewCellSelectionStyleNone;
        progressBarCell.isLeftRightPadding = YES;
        progressBarCell.cellHeight = [self tableView:tableView heightForRowAtIndexPath:indexPath];
        [self.tableView setCellView:progressBarCell inRow:0 inSection:indexPath.section];
    }
    
    //判读有无数据，有数据就加载页面
    if(progressBarCell.objectValue){
        NSString *keyValue = [NSString stringWithFormat:@"gkkb-%ld-%ld",indexPath.section,indexPath.row];
        EnterprisesViewCell *cell = [self.tableView getCellViewKey:keyValue];
        if (!cell) {
            cell = [[EnterprisesViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:keyValue index:1];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            [self.tableView setCellView:cell key:keyValue];
            
            NSArray *valueArray1 = [progressBarCell.objectValue objectAtIndexFormat:0];
            NSDictionary *itemValue1 = [valueArray1 objectAtIndexDictionary:0];
            cell.XS_BRFL_Label.text = [itemValue1 objectFormatFloatStringForKey:@"本日产量" retain:1  format:@"%@"];
            cell.XS_BYFL_Label.text = [itemValue1 objectFormatFloatStringForKey:@"本月产量" retain:1 format:@"本月方量：%@"];
            cell.XS_BRCZ_Label.text = [itemValue1 objectFormatFloatStringForKey:@"本日产值" retain:0 format:@"¥%@"];
            cell.XS_BYCZ_Label.text = [itemValue1 objectFormatFloatStringForKey:@"本月产值" retain:0 format:@"本月产值：¥%@"];
            //cell.XS_BNFL_Label.text = [itemValue1 objectFormatFloatStringForKey:@"本年产量" retain:1 format:@"本年方量：%@"];
            
            NSArray *valueArray2 = [progressBarCell.objectValue objectAtIndexFormat:1];
            NSDictionary *itemValue2 = [valueArray2 objectAtIndexDictionary:0];
            cell.XS_ZYCCB_Label.text = [itemValue2 objectFormatFloatForKey:@"总原材成本" retain:1 except:10000 format:@"¥%@"];
            cell.XS_NZCZ_Label.text = [itemValue2 objectFormatFloatForKey:@"年总产值" retain:1 except:10000 format:@"¥%@"];
            cell.XS_MLL_Label.text = [itemValue2 objectFormatFloatStringForKey:@"毛利率" retain:2 format:@"%@%%"];
            cell.XS_MLR_Label.text = [itemValue2 objectFormatFloatForKey:@"总毛利润" retain:1 except:10000 format:@"总毛利润：¥%@"];
            //cell.XS_BNCZ_Label.text = [itemValue2 objectFormatFloatStringForKey:@"本年产值" retain:0 format:@"本年产值：¥%@"];
            
        }
        return cell;
    }
    
    [progressBarCell getNetWorkDataTableView:tableView moduleType:@"QYKB_XS_HOME" parameter:nil StationID:[_stationId integerValue] interfaceType:0 index:indexPath.section];
    return progressBarCell;
}

//原材采购
-(UITableViewCell*)getYCCGView:(UITableView *)tableView path:(NSIndexPath *)indexPath
{
    GEProgressBarTableViewCell *progressBarCell = [self.tableView getCellViewInRow:0 inSection:indexPath.section];
    if (progressBarCell == nil) {
        NSString *identifierBar = [NSString stringWithFormat:@"GEProgressBarTableViewCell%ld",indexPath.section];
        progressBarCell = [[GEProgressBarTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifierBar];
        progressBarCell.selectionStyle = UITableViewCellSelectionStyleNone;
        progressBarCell.isLeftRightPadding = YES;
        progressBarCell.cellHeight = [self tableView:tableView heightForRowAtIndexPath:indexPath];
        [self.tableView setCellView:progressBarCell inRow:0 inSection:indexPath.section];
    }
    
    //判读有无数据，有数据就加载页面
    if(progressBarCell.objectValue){
        NSArray *valueArray = [progressBarCell.objectValue objectAtIndexFormat:0];
        if(valueArray.count<=0){//无数据处理
            [progressBarCell drawNotDataViewTableView:tableView];
            progressBarCell.objectValue = NULL;
            return progressBarCell;
        }
        
        NSString *keyValue = [NSString stringWithFormat:@"gkkb-%ld-%ld",indexPath.section,indexPath.row];
        EnterprisesViewCell *cell = [self.tableView getCellViewKey:keyValue];
        if (!cell) {
            cell = [[EnterprisesViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:keyValue index:2];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            [self.tableView setCellView:cell key:keyValue];
            
            for(int i=0;i<valueArray.count;i++){
                NSDictionary *itemValue = [valueArray objectAtIndexDictionary:i];
                NSInteger width = cell.frame.size.width;
                NSInteger height = 20;
                NSInteger y = 32 + i*height;
                
                UILabel *clmcLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, y, 128, height)];
                clmcLabel.font = [UIFont systemFontOfSize:13];
                clmcLabel.textColor = [UIColor colorWithRed:42/255.0 green:141/255.0 blue:228/255.0 alpha:1];
                clmcLabel.text = [itemValue objectFormatStringForKey:@"材料" defaults:@"-"];
                clmcLabel.textAlignment = NSTextAlignmentLeft;
                [cell addSubview:clmcLabel];
                
                UILabel *brLabel = [[UILabel alloc] initWithFrame:CGRectMake(130, y, (width-130)/3, height)];
                brLabel.font = [UIFont systemFontOfSize:15];
                brLabel.text = [itemValue objectFormatFloatForKey:@"本日" retain:1 except:1000 format:@"%@"];
                brLabel.textColor = [UIColor colorWithRed:128/255.0 green:128/255.0 blue:128/255.0 alpha:1];
                brLabel.textAlignment = NSTextAlignmentCenter;
                [cell addSubview:brLabel];
                
                UILabel *byLabel = [[UILabel alloc] initWithFrame:CGRectMake(130+(width-130)/3, y, (width-130)/3, height)];
                byLabel.font = [UIFont systemFontOfSize:15];
                byLabel.text = [itemValue objectFormatFloatForKey:@"本月" retain:1 except:1000 format:@"%@"];
                byLabel.textColor = [UIColor colorWithRed:128/255.0 green:128/255.0 blue:128/255.0 alpha:1];
                byLabel.textAlignment = NSTextAlignmentCenter;
                [cell addSubview:byLabel];
                
                UILabel *bnmcLabel = [[UILabel alloc] initWithFrame:CGRectMake(130+(width-130)/3*2, y, (width-130)/3, height)];
                bnmcLabel.font = [UIFont systemFontOfSize:15];
                //bnmcLabel.text = [itemValue objectFormatFloatStringForKey:@"本年" retain:1 format:@"%@"];
                bnmcLabel.text = [itemValue objectFormatFloatForKey:@"本年" retain:1 except:1000 format:@"%@"];
                bnmcLabel.textColor = [UIColor colorWithRed:128/255.0 green:128/255.0 blue:128/255.0 alpha:1];
                bnmcLabel.textAlignment = NSTextAlignmentCenter;
                [cell addSubview:bnmcLabel];
            }
            
        }
        return cell;
    }
    
    [progressBarCell getNetWorkDataTableView:tableView moduleType:@"QYKB_YCCG_HOME_01" parameter:nil StationID:[_stationId integerValue] interfaceType:0 index:indexPath.section];
    return progressBarCell;
}

//原材消耗
-(UITableViewCell*)getYCXHView:(UITableView *)tableView path:(NSIndexPath *)indexPath
{
    GEProgressBarTableViewCell *progressBarCell = [self.tableView getCellViewInRow:0 inSection:indexPath.section];
    if (progressBarCell == nil) {
        NSString *identifierBar = [NSString stringWithFormat:@"GEProgressBarTableViewCell%ld",indexPath.section];
        progressBarCell = [[GEProgressBarTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifierBar];
        progressBarCell.selectionStyle = UITableViewCellSelectionStyleNone;
        progressBarCell.isLeftRightPadding = YES;
        progressBarCell.cellHeight = [self tableView:tableView heightForRowAtIndexPath:indexPath];
        [self.tableView setCellView:progressBarCell inRow:0 inSection:indexPath.section];
    }
    
    //判读有无数据，有数据就加载页面
    if(progressBarCell.objectValue){
        NSArray *valueArray = [progressBarCell.objectValue objectAtIndexFormat:0];
        if(valueArray.count<=0){//无数据处理
            [progressBarCell drawNotDataViewTableView:tableView];
            progressBarCell.objectValue = NULL;
            return progressBarCell;
        }
        
        NSString *keyValue = [NSString stringWithFormat:@"gkkb-%ld-%ld",indexPath.section,indexPath.row];
        EnterprisesViewCell *cell = [self.tableView getCellViewKey:keyValue];
        if (!cell) {
            cell = [[EnterprisesViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:keyValue index:3];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            [self.tableView setCellView:cell key:keyValue];
            
            for(int i=0;i<valueArray.count;i++){
                NSDictionary *itemValue = [valueArray objectAtIndexDictionary:i];
                NSInteger width = cell.frame.size.width;
                NSInteger height = 20;
                NSInteger y = 32 + i*height;
                
                UILabel *clmcLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, y, width/4, height)];
                clmcLabel.font = [UIFont systemFontOfSize:14];
                clmcLabel.textColor = [UIColor colorWithRed:42/255.0 green:141/255.0 blue:228/255.0 alpha:1];
                clmcLabel.text = [itemValue objectFormatStringForKey:@"材料" defaults:@"-"];
                clmcLabel.textAlignment = NSTextAlignmentCenter;
                [cell addSubview:clmcLabel];
                
                UILabel *brLabel = [[UILabel alloc] initWithFrame:CGRectMake(width/4*1, y, width/4, height)];
                brLabel.font = [UIFont systemFontOfSize:15];
                brLabel.text = [itemValue objectFormatFloatForKey:@"本日" retain:1 except:1000 format:@"%@"];
                brLabel.textColor = [UIColor colorWithRed:128/255.0 green:128/255.0 blue:128/255.0 alpha:1];
                brLabel.textAlignment = NSTextAlignmentCenter;
                [cell addSubview:brLabel];
                
                UILabel *byLabel = [[UILabel alloc] initWithFrame:CGRectMake(width/4*2, y, width/4, height)];
                byLabel.font = [UIFont systemFontOfSize:15];
                byLabel.text = [itemValue objectFormatFloatForKey:@"本月" retain:1 except:1000 format:@"%@"];
                byLabel.textColor = [UIColor colorWithRed:128/255.0 green:128/255.0 blue:128/255.0 alpha:1];
                byLabel.textAlignment = NSTextAlignmentCenter;
                [cell addSubview:byLabel];
                
                UILabel *bnmcLabel = [[UILabel alloc] initWithFrame:CGRectMake(width/4*3, y, width/4, height)];
                bnmcLabel.font = [UIFont systemFontOfSize:15];
                bnmcLabel.text = [itemValue objectFormatFloatForKey:@"本年" retain:1 except:1000 format:@"%@"];
                bnmcLabel.textColor = [UIColor colorWithRed:128/255.0 green:128/255.0 blue:128/255.0 alpha:1];
                bnmcLabel.textAlignment = NSTextAlignmentCenter;
                [cell addSubview:bnmcLabel];
            }
        }
        return cell;
    }
    
    [progressBarCell getNetWorkDataTableView:tableView moduleType:@"QYKB_YCXH_HOME" parameter:nil StationID:[_stationId integerValue] interfaceType:0 index:indexPath.section];
    return progressBarCell;
}

//柴油
-(UITableViewCell*)getCYView:(UITableView *)tableView path:(NSIndexPath *)indexPath
{
    GEProgressBarTableViewCell *progressBarCell = [self.tableView getCellViewInRow:0 inSection:indexPath.section];
    if (progressBarCell == nil) {
        NSString *identifierBar = [NSString stringWithFormat:@"GEProgressBarTableViewCell%ld",indexPath.section];
        progressBarCell = [[GEProgressBarTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifierBar];
        progressBarCell.selectionStyle = UITableViewCellSelectionStyleNone;
        progressBarCell.isLeftRightPadding = YES;
        progressBarCell.cellHeight = [self tableView:tableView heightForRowAtIndexPath:indexPath];
        [self.tableView setCellView:progressBarCell inRow:0 inSection:indexPath.section];
    }
    
    //判读有无数据，有数据就加载页面
    if(progressBarCell.objectValue){
        NSString *keyValue = [NSString stringWithFormat:@"gkkb-%ld-%ld",indexPath.section,indexPath.row];
        EnterprisesViewCell *cell = [self.tableView getCellViewKey:keyValue];
        if (!cell) {
            cell = [[EnterprisesViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:keyValue index:4];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            [self.tableView setCellView:cell key:keyValue];
            
            NSArray *valueArray1 = [progressBarCell.objectValue objectAtIndexFormat:0];
            NSDictionary *itemValue1 = [valueArray1 objectAtIndexDictionary:0];
            cell.CYTJ_CG_BRSL_Label.text = [itemValue1 objectFormatFloatStringForKey:@"本日采购数量" retain:1 format:@"%@"];
            cell.CYTJ_CG_BRJE_Label.text = [itemValue1 objectFormatFloatStringForKey:@"本日采购金额" retain:1 format:@"¥%@"];
            cell.CYTJ_CG_BYSL_Label.text = [itemValue1 objectFormatFloatStringForKey:@"本月采购数量" retain:1 format:@"%@"];
            cell.CYTJ_CG_BYJE_Label.text = [itemValue1 objectFormatFloatStringForKey:@"本月采购金额" retain:1 format:@"¥%@"];
            cell.CYTJ_CG_BNSL_Label.text = [itemValue1 objectFormatFloatStringForKey:@"本年采购数量" retain:1 format:@"%@"];
            cell.CYTJ_CG_BNJE_Label.text = [itemValue1 objectFormatFloatStringForKey:@"本年采购金额" retain:1 format:@"¥%@"];
            
            NSArray *valueArray2 = [progressBarCell.objectValue objectAtIndexFormat:0];
            NSDictionary *itemValue2 = [valueArray2 objectAtIndexDictionary:0];
            cell.CYTJ_XH_BRSL_Label.text = [itemValue2 objectFormatFloatStringForKey:@"本日消耗数量" retain:1 format:@"%@"];
            cell.CYTJ_XH_BRJE_Label.text = [itemValue2 objectFormatFloatStringForKey:@"本日消耗金额" retain:1 format:@"¥%@"];
            cell.CYTJ_XH_BYSL_Label.text = [itemValue2 objectFormatFloatStringForKey:@"本月消耗数量" retain:1 format:@"%@"];
            cell.CYTJ_XH_BYJE_Label.text = [itemValue2 objectFormatFloatStringForKey:@"本月消耗金额" retain:1 format:@"¥%@"];
            cell.CYTJ_XH_BNSL_Label.text = [itemValue2 objectFormatFloatStringForKey:@"本年消耗数量" retain:1 format:@"%@"];
            cell.CYTJ_XH_BNJE_Label.text = [itemValue2 objectFormatFloatStringForKey:@"本年消耗金额" retain:1 format:@"¥%@"];
            
            
        }
        return cell;
    }
    
    [progressBarCell getNetWorkDataTableView:tableView moduleType:@"QYKB_CY_HOME" parameter:nil StationID:[_stationId integerValue] interfaceType:0 index:indexPath.section];
    return progressBarCell;
}

//砼收款
-(UITableViewCell*)getTSKView:(UITableView *)tableView path:(NSIndexPath *)indexPath
{
    GEProgressBarTableViewCell *progressBarCell = [self.tableView getCellViewInRow:0 inSection:indexPath.section];
    if (progressBarCell == nil) {
        NSString *identifierBar = [NSString stringWithFormat:@"GEProgressBarTableViewCell%ld",indexPath.section];
        progressBarCell = [[GEProgressBarTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifierBar];
        progressBarCell.selectionStyle = UITableViewCellSelectionStyleNone;
        progressBarCell.isLeftRightPadding = YES;
        progressBarCell.cellHeight = [self tableView:tableView heightForRowAtIndexPath:indexPath];
        [self.tableView setCellView:progressBarCell inRow:0 inSection:indexPath.section];
    }
    
    //判读有无数据，有数据就加载页面
    if(progressBarCell.objectValue){
        NSString *keyValue = [NSString stringWithFormat:@"gkkb-%ld-%ld",indexPath.section,indexPath.row];
        EnterprisesViewCell *cell = [self.tableView getCellViewKey:keyValue];
        if (!cell) {
            NSArray *valueArray = [progressBarCell.objectValue objectAtIndexFormat:0];
            cell = [[EnterprisesViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:keyValue index:5];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            [self.tableView setCellView:cell key:keyValue];
            
            NSDictionary *itemValue = [valueArray objectAtIndexDictionary:0];
            cell.TSK_BYSK_Label.text = [itemValue objectFormatFloatForKey:@"本月金额" retain:1 except:10000 format:@"¥%@"];
            cell.TSK_BNJE_Label.text = [itemValue objectFormatFloatForKey:@"本年金额" retain:1 except:10000 format:@"本年总收款：¥%@"];
            cell.TSK_BNSK_Label.text = [itemValue objectFormatFloatForKey:@"本年产值" retain:1 except:10000 format:@"本年砼产值：¥%@"];
        }
        return cell;
    }
    
    [progressBarCell getNetWorkDataTableView:tableView moduleType:@"QYKB_TSK_HOME" parameter:nil StationID:[_stationId integerValue] interfaceType:0 index:indexPath.section];
    return progressBarCell;
}

//应付款
-(UITableViewCell*)getYFKView:(UITableView *)tableView path:(NSIndexPath *)indexPath
{
    GEProgressBarTableViewCell *progressBarCell = [self.tableView getCellViewInRow:0 inSection:indexPath.section];
    if (progressBarCell == nil) {
        NSString *identifierBar = [NSString stringWithFormat:@"GEProgressBarTableViewCell%ld",indexPath.section];
        progressBarCell = [[GEProgressBarTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifierBar];
        progressBarCell.selectionStyle = UITableViewCellSelectionStyleNone;
        progressBarCell.isLeftRightPadding = YES;
        progressBarCell.cellHeight = [self tableView:tableView heightForRowAtIndexPath:indexPath];
        [self.tableView setCellView:progressBarCell inRow:0 inSection:indexPath.section];
    }
    
    //判读有无数据，有数据就加载页面
    if(progressBarCell.objectValue){
        NSString *keyValue = [NSString stringWithFormat:@"gkkb-%ld-%ld",indexPath.section,indexPath.row];
        EnterprisesViewCell *cell = [self.tableView getCellViewKey:keyValue];
        if (!cell) {
            NSArray *valueArray = [progressBarCell.objectValue objectAtIndexFormat:0];
            cell = [[EnterprisesViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:keyValue index:6];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            [self.tableView setCellView:cell key:keyValue];
            
            NSDictionary *itemValue = [valueArray objectAtIndexDictionary:0];
            cell.YFK_BYJE_Label.text = [itemValue objectFormatFloatForKey:@"本月金额" retain:1 except:10000 format:@"¥%@"];
            cell.YFK_BNJE_Label.text = [itemValue objectFormatFloatForKey:@"本年金额" retain:1 except:10000 format:@"本年总应付：¥%@"];
        }
        return cell;
    }
    
    [progressBarCell getNetWorkDataTableView:tableView moduleType:@"QYKB_YCYFK_HOME" parameter:nil StationID:[_stationId integerValue] interfaceType:0 index:indexPath.section];
    return progressBarCell;
}

//砼方量统计
-(UITableViewCell*)getTFLTJView:(UITableView *)tableView path:(NSIndexPath *)indexPath
{
    GEProgressBarTableViewCell *progressBarCell = [self.tableView getCellViewInRow:0 inSection:indexPath.section];
    if (progressBarCell == nil) {
        NSString *identifierBar = [NSString stringWithFormat:@"GEProgressBarTableViewCell%ld",indexPath.section];
        progressBarCell = [[GEProgressBarTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifierBar];
        progressBarCell.selectionStyle = UITableViewCellSelectionStyleNone;
        progressBarCell.isLeftRightPadding = YES;
        progressBarCell.cellHeight = [self tableView:tableView heightForRowAtIndexPath:indexPath];
        [self.tableView setCellView:progressBarCell inRow:0 inSection:indexPath.section];
    }
    
    //判读有无数据，有数据就加载页面
    if(progressBarCell.objectValue){
        NSArray *valueArray = [progressBarCell.objectValue objectAtIndexFormat:0];
        if(valueArray.count<=0){//无数据处理
            [progressBarCell drawNotDataViewTableView:tableView];
            progressBarCell.objectValue = NULL;
            return progressBarCell;
        }
        
        NSString *keyValue = [NSString stringWithFormat:@"gkkb-%ld-%ld",indexPath.section,indexPath.row];
        EnterprisesViewCell *cell = [self.tableView getCellViewKey:keyValue];
        if (!cell) {
            cell = [[EnterprisesViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:keyValue index:8];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            [self.tableView setCellView:cell key:keyValue];
            
            for(int i=0;i<valueArray.count;i++){
                NSDictionary *itemValue = [valueArray objectAtIndexDictionary:i];
                NSInteger width = cell.frame.size.width;
                NSInteger height = 24;
                NSInteger y = 32 + i*height;
                
                UILabel *clmcLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, y, width/4, height)];
                clmcLabel.font = [UIFont systemFontOfSize:15];
                clmcLabel.textColor = [UIColor colorWithRed:42/255.0 green:141/255.0 blue:228/255.0 alpha:1];
                clmcLabel.text = [itemValue objectFormatStringForKey:@"日期" defaults:@"-"];
                clmcLabel.textAlignment = NSTextAlignmentCenter;
                [cell addSubview:clmcLabel];
                
                UILabel *brLabel = [[UILabel alloc] initWithFrame:CGRectMake(width/4, y, width/4, height)];
                brLabel.font = [UIFont systemFontOfSize:15];
                brLabel.text = [itemValue objectFormatFloatForKey:@"生产方量" retain:1 except:1 format:@"%@"];
                brLabel.textColor = [UIColor colorWithRed:128/255.0 green:128/255.0 blue:128/255.0 alpha:1];
                brLabel.textAlignment = NSTextAlignmentCenter;
                [cell addSubview:brLabel];
                
                UILabel *byLabel = [[UILabel alloc] initWithFrame:CGRectMake(width/4*2, y, width/4, height)];
                byLabel.font = [UIFont systemFontOfSize:15];
                byLabel.text = [itemValue objectFormatFloatForKey:@"发货方量" retain:1 except:1 format:@"%@"];
                byLabel.textColor = [UIColor colorWithRed:128/255.0 green:128/255.0 blue:128/255.0 alpha:1];
                byLabel.textAlignment = NSTextAlignmentCenter;
                [cell addSubview:byLabel];
                
                UILabel *bnmcLabel = [[UILabel alloc] initWithFrame:CGRectMake(width/4*3, y, width/4, height)];
                bnmcLabel.font = [UIFont systemFontOfSize:15];
                bnmcLabel.text = [itemValue objectFormatFloatForKey:@"签收方量" retain:1 except:1 format:@"%@"];
                bnmcLabel.textColor = [UIColor colorWithRed:128/255.0 green:128/255.0 blue:128/255.0 alpha:1];
                bnmcLabel.textAlignment = NSTextAlignmentCenter;
                [cell addSubview:bnmcLabel];
            }
        }
        return cell;
    }
    
    [progressBarCell getNetWorkDataTableView:tableView moduleType:@"QYKB_FLTJ_HOME" parameter:nil StationID:[_stationId integerValue] interfaceType:0 index:indexPath.section];
    return progressBarCell;
}

@end
